//顶部大选项卡切换
var aBigLi = document.getElementsByClassName('top')[0].getElementsByTagName('li');
for(var i=0;i<aBigLi.length;i++){
	aBigLi[i].onclick = function(){
		for(var j = 0;j<aBigLi.length;j++){
			aBigLi[j].className = ''
		}
		this.className = 'cur'
	}
}

//分类选项卡切换
var aClassLi = document.getElementsByClassName('tab-class')[0].getElementsByTagName('li');
for(var i=0;i<aClassLi.length;i++){
	aClassLi[i].onclick = function(){
		for(var j = 0;j<aClassLi.length;j++){
			if(aClassLi[j].className.indexOf('only') !== -1){
				aClassLi[j].className = 'only';
			}
			else{
				aClassLi[j].className = '';
			}
		}
		this.className += ' cur';
	}
}

//状态选项卡切换
var aStatusLi = document.getElementsByClassName('tab-status')[0].getElementsByTagName('li');
for(var i=0;i<aStatusLi.length;i++){
	aStatusLi[i].onclick = function(){
		for(var j = 0;j<aStatusLi.length;j++){
			aStatusLi[j].className = ''
		}
		this.className = 'cur'
	}
}

//分页切换
var aPageList = document.getElementsByClassName('page-box')[0].getElementsByTagName('li');
for(var i=1;i<aPageList.length-1;i++){
	aPageList[i].onclick = function(){
		for(var j = 1;j<aPageList.length-1;j++){
			aPageList[j].className = ''
		}
		this.className = 'currentpage'
	}
}

//问题描述展开收起(内容超范围折叠隐藏)
var aHotQuestionDesc = document.getElementsByClassName('person-hot-ask');
for(var i = 0;i<aHotQuestionDesc.length;i++){
	var oldInnerHtml = aHotQuestionDesc[i].innerHTML;
	if(aHotQuestionDesc[i].innerHTML.length>150){
		aHotQuestionDesc[i].innerHTML = aHotQuestionDesc[i].innerHTML.substring(0,150) + '...' + '<a href="javascript:;" style="color:#1966FF;font-weight:400;" onclick="pullout(this)">展开∨</a>';
		aHotQuestionDesc[i].setAttribute('content-str',oldInnerHtml);
	}
}
//展开收起动作
function pullout(item){
	var oParent = item.parentNode;
	var oAllStr = oParent.getAttribute('content-str');
	oParent.innerHTML = oAllStr + '<em style="font-weight:400;cursor:pointer;color:#000;" onclick="closein(this)">收起∧</em>';
}

function closein(item){
	var oParent = item.parentNode;
	var oAllStr = oParent.getAttribute('content-str');
	oParent.innerHTML = oAllStr.substring(0,150) + '...' + '<a href="javascript:;" style="color:#1966FF;font-weight:400;" onclick="pullout(this)">展开∨</a>';
}

//答题弹窗
var oShowAnswerBtn = document.getElementById('show-answer-box');
var oAnswerEditBox = document.getElementById('answer-edit-box');
oShowAnswerBtn.onclick = function(){
	oAnswerEditBox.style.display = 'block';
}

//课程问答追问弹出表单
var aGoingAskBtn = document.getElementsByClassName('going-ask-btn');
var aGoingAskForm = document.getElementsByTagName('form');
for(var i = 0;i<aGoingAskBtn.length;i++){
	aGoingAskBtn[i].index = i;
	aGoingAskBtn[i].onclick = function(){
		for(var j = 0;j<aGoingAskBtn.length;j++){
			aGoingAskForm[j].style.display = 'none';
		}
		aGoingAskForm[this.index].style.display = 'block';
	}
}


//我的悬赏追问弹出表单
var aQuestioningBtn = document.getElementsByClassName('questioning');
var aQuestioningForm = document.getElementsByTagName('form');
for(var i = 0;i<aQuestioningBtn.length;i++){
	aQuestioningBtn[i].index = i;
	aQuestioningBtn[i].onclick = function(){
		for(var j = 0;j<aQuestioningBtn.length;j++){
			aQuestioningForm[j].style.display = 'none';
		}
		aQuestioningForm[this.index].style.display = 'block';
	}
}

